<h1>Usuários</h1>
<table class="table">
    <thead>
		<tr>
			<th><?php echo $this->Paginator->sort('username', 'Nome de Usuário');?>  </th>
			<th><?php echo $this->Paginator->sort('email', 'E-Mail');?></th>
			<th><?php echo $this->Paginator->sort('created', 'Data de Cadastro');?></th>
			<th><?php echo $this->Paginator->sort('last_access','Último Acesso');?></th>
			<th><?php echo $this->Paginator->sort('role','Role');?></th>
			<th>Ações</th>
		</tr>
	</thead>
	<tbody>
		<?php foreach($users as $user): ?>
		<tr>
			<td><?php echo $this->Html->link($user['User']['username']  ,   array('action'=>'edit', $user['User']['id']),array('escape' => false) );?></td>
			<td><?php echo $user['User']['email']; ?></td>
			<td><?php echo date('d/m/Y H:i:s', strtotime($user['User']['created'])); ?></td>
			<td><?php echo date('d/m/Y H:i:s', strtotime($user['User']['last_access'])); ?></td>
			<td><?php echo $user['User']['role']; ?></td>
			<td>
        <?php if($user['User']['role'] == 'admin'): ?>
        <?php echo $this->Html->link("Tornar Cliente", array('action'=>'tornar_cliente', $user['User']['id']), array('class'=>'btn btn-default')); ?>
        <?php else: ?>
        <?php echo $this->Html->link("Tornar Admin", array('action'=>'tornar_admin', $user['User']['id']), array('class'=>'btn btn-default')); ?>
        <?php endif ?>
			  <?php echo $this->Html->link("Desativar", array('action'=>'delete', $user['User']['id']), array('class'=>'btn btn-default')); ?>
			</td>
		</tr>
		<?php endforeach; ?>
	</tbody>
</table>
<div class="col-md-12" style="text-align: center;">
    <?php
    echo $this->Paginator->first('Primeira página ');
    echo $this->Paginator->numbers();
    echo $this->Paginator->last(' Última página');
    ?>

    <br />

    <?php
    echo $this->Paginator->counter(
        'Página {:page} de {:pages}, exibindo {:current} de
         {:count} usuários'
    );
    //, starting on record {:start}, ending on {:end}
    ?>
</div>
